package org.clockworkmages.games.anno1186.util;

public class MathUtil {

	private MathUtil() {

	}

	public static int zeroIfNull(Integer i) {
		if (i == null) {
			return 0;
		} else {
			return i.intValue();
		}
	}

	public static double zeroIfNull(Double i) {
		if (i == null) {
			return 0;
		} else {
			return i.intValue();
		}
	}

	public static double zeroOrMore(double d) {
		if (d < 0) {
			return 0d;
		} else {
			return d;
		}
	}

	public static int experienceNeededToLevelUp(int level) {
		// 100 to advance to lv2, 110 to advance to lv3 etc.
		int experienceNeededToLevelUp = level * 80 + (level + 1) * (level) / 2
				* 10;
		return experienceNeededToLevelUp;
	}
}
